04. Java Basic APIs - StringBuilder, StringBuffer, Regex

035ND C01 L01 A02 STRINGBUILDER, STRING, REGEX

The StringBuilder and StringBuffer class creates a mutable sequence of characters.
Different than String, StringBuilder and StringBuffer are mutable. Both classes create a mutable sequence of characters. And they are very much similar to each other.

However the StringBuilder provides no guarantee of synchronization whereas the StringBuffer class does. And Regex, aka, regular expression, is used to match or filter out Strings. Again, please take a look at the APIs docs on your own, and see if you can solve the quizzes and the coding problems

Resources:

StringBuilder: https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html

StringBuffer: https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuffer.html

Regex: https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html

StringBuilder sb = new StringBuilder("Good Morning");
sb.insert(1, "Friend ");
System.out.println(sb.toString()); 

What is the console output?

SOLUTION: Some other output

What is the following Regex expression trying to validate?

^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$
SOLUTION: An email address

StringBuilder, StringBuffer, Regex Coding exercise

Task Description:

Write a method with a random string input, returns a String containing only vowels.
Example:

Input: “Hello World!” -> output: “eoo”

Input: “Udacity Course” -> output: “Uaioue”

Skeleton of code

public static String vowelOnly(String input) {
}
Task List:

Task Feedback:

Great job!
Solution for your reference: https://github.com/udacity/JDND/tree/master/exercises/c1/exercises

035ND C01 L01 A03 CODING EXERCISES SOLUTION